HA$PBExportHeader$u_cst_museralma.sru
forward
global type u_cst_museralma from u_cst_mantocabedet
end type
end forward

global type u_cst_museralma from u_cst_mantocabedet
boolean dw_has_focus = false
long il_id = 0
long il_error = 0
long il_codigo = 0
integer ii_currentrow = 0
integer ii_row = 0
integer ii_sw = 0
integer ii_idcodigo = 0
integer ii_codigo = 0
integer ii_window = 0
end type
global u_cst_museralma u_cst_museralma

type variables
long il_documento 
boolean ib_printGrabar=false
end variables

forward prototypes
public subroutine of_retrieve (long al_codigo)
public function boolean of_verificar_datos_detalle ()
end prototypes

public subroutine of_retrieve (long al_codigo);dw_1.retrieve(al_codigo);
//dw_3.event ue_dropdowndw()
dw_3.retrieve(al_codigo); commit;
end subroutine

public function boolean of_verificar_datos_detalle ();double ld_nstock,ld_cant
//long ll_fila
String ls_item
integer li_fila,li_alma,li_item

//For li_fila = 1 To dw_3.RowCount()
//	li_item = dw_3.object.iditem[li_fila]
//	li_alma = dw_3.object.idalma[li_fila]
//	ld_cant = dw_3.object.ncant[li_fila]
//	//-- Valores ceros y nulos
//	If dw_3.GetItemDecimal(li_fila,'ncant') = 0 Or 	dw_3.GetItemDecimal(li_fila,'npreciobase') = 0 Then 
//		MessageBox('Advertencia','Error, Cantidad Digitada no Puede Ser Cero',stopsign!)
//		Return False
//	end if
//		
//	//-- Actualiza el numero de oc
//	//idw_detalle.SetItem(ll_fila,'cc_ordcom', idw_ficha.object.cc_ordcom[1])
//	sqlca.usp_getstockmitemalma( li_item,li_alma,ld_nstock)
//	if isnull(ld_nstock) then ld_nstock = 0
//	if ld_cant > ld_nstock then
//		dw_3.object.nstock[li_fila] = ld_nstock
//		f_msg('El stock actual es menor a la cantidad de salida ',1); return false
//	end if
//Next

Return True

end function

on u_cst_museralma.create
int iCurrent
call super::create
end on

on u_cst_museralma.destroy
call super::destroy
end on

event ue_nuevo;string ls_correlativo
long ll_movimiento
//return 0
//ll_movimiento=0
//sqlca.Usp_GetIdTablaINT(is_tabla,ll_movimiento)
//dw_1.object.iddocumento[1]=ll_movimiento
//
//ls_correlativo = space(14)
//SqlCA.usp_getcodigodocvta( 6,ls_correlativo)
//
//dw_1.object.tDocumento[dw_1.rowcount()] = ls_correlativo
//dw_1.object.femision     [dw_1.rowcount()] = today()
//dw_1.object.idDocu       [dw_1.rowcount()] = 6
end event

event ue_agregar;integer li_row,li_fila,li_alma
string ls_criterio,ls_alma
If f_findrequired(dw_1) = -1 Then Return 


li_alma = dw_1.object.idalma[1]

dw_3.scrolltorow( dw_3.InsertRow(0))
//if li_row = 0 then
//	dw_3.object.idindice [li_fila ]=	1
//else
//	dw_3.object.idindice [dw_3.rowcount()]=	dw_3.object.idindice [li_row]+1
//end if
//dw_3.GetChild("iditem", dwc);dwc.reset()
//gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)

//ls_alma = string(dw_1.object.idalma[1])
//ls_criterio="string(idalma)= '"+ls_alma+"'"
//f_filtrar_item(dw_3,dwc,dwc2,ls_criterio)
//f_msg(string( dwc.rowcount( )) ,1)
//
dw_3.object.idalma [dw_3.rowcount()] =dw_1.object.idalma[1]
dw_3.object.idindice [dw_3.rowcount()]=dw_3.rowcount()


end event

event ue_grabar_previo;LONG ll_movimiento
integer li_fila
CHOOSE CASE UPPER(is_button)
	case 'NUEVO'
//		ll_movimiento=0
//		sqlca.Usp_GetIdTablaINT(is_tabla,ll_movimiento)
//		dw_1.object.idDOCUMENTO  [1]=ll_movimiento
//		il_documento=ll_movimiento
//		//dw_1.object.tdocumento    [1] = of_getTDocumento()
//		dw_1.object.fproceso         [1] =today()
//		if ib_printGrabar then
//			dw_1.object.bimpreso         [1]=1
//		end if
//		
//		event ue_sumar()
//		for li_fila =1 to dw_3.rowcount( )
//				dw_3.object.idindice  [li_fila] = li_fila
//				dw_3.object.idDOCUMENTO  [li_fila] = dw_1.object.idDOCUMENTO  [1]
//				//dw_3.object.fproceso         [li_fila] =	dw_1.object.fproceso         [1] 
//				//dw_3.object.idcentro          [li_fila] =	dw_1.object.idcentro         [1] 
//				dw_3.object.idalma            [li_fila] =	dw_1.object.idalma         [1] 
//				//dw_3.object.idtrans            [li_fila] =	dw_1.object.idtrans         [1] 
//				//dw_3.object.idmoneda        [li_fila] =	dw_1.object.idMoneda         [1] 
//				
//		next
	case 'EDITAR'
	//	for li_fila =1 to dw_3.rowcount( )
		
				//dw_3.object.idDOCUMENTO  [li_fila] = dw_1.object.idDOCUMENTO  [1]
//				dw_3.object.fproceso         [li_fila] =	dw_1.object.fproceso         [1] 
				//dw_3.object.idcentro          [li_fila] =	dw_1.object.idcentro         [1] 
				//dw_3.object.idalma            [li_fila] =dw_1.object.idalma         [1] 
//				dw_3.object.idtrans            [li_fila] =	dw_1.object.idtrans         [1] 
//				dw_3.object.idmoneda        [li_fila] =	dw_1.object.idMoneda         [1] 
		//next
		
		//DELETE FROM MKARDEX WHERE IDMOVIDOCU = :il_codigo;
		
		
		
END CHOOSE
end event

event ue_setdwc;//choose case is_tabla
//	case 'MMOVIMIENTO'
//dw_2.GetChild("idvend", dwc);dwc.reset();	dwc.settransobject( sqlca);	dwc.retrieve( )
//dw_2.GetChild("idcond", dwc);dwc.reset();	dwc.settransobject( sqlca);	dwc.retrieve( )
//dw_2.GetChild("idclie", dwc);dwc.reset();	dwc.settransobject( sqlca);	dwc.retrieve( )
dw_2.GetChild("idcentro", dwc);dwc.reset();	dwc.settransobject( sqlca);	dwc.retrieve( )
dw_4.GetChild("iditem", dwc);dwc.reset();	dwc.settransobject( sqlca);	dwc.retrieve( )
			
commit;
end event

event ue_grabar_pos;//dw_4.GetChild("iditem", dwc);dwc.reset()
//gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)
//dw_1.reset();dw_3.reset( )
iuo_grillamain.event ue_activa_opc( false)
this.event ue_cambio_opc('Consultar')
this.event ue_settabtext( 'Consultar')

dw_1.reset();dw_3.reset( )
iuo_grillamain.event dynamic ue_activa_opc(false) 
iuo_grillamain.event dynamic ue_bloquear_refrescar(false) 
this.event ue_setdwc()

//if ib_printgrabar then
//	this.event ue_imprimir()

//end if
	
//this.event ue_nuevo()
end event

event ue_grabar_otros;//
//long ll_documento
//ll_documento = DW_1.OBJECT.iddocumento[1]
//If sqlca.Usp_AddMKARDEX_Venta(ll_documento) <> 0  Then
//	rollback USING SQLCA ;
//	f_msj('Error al insertar al kardex',1)
//	return FALSE
//End if
//
return TRUE


end event

event constructor;call super::constructor;string ls_dw3,ls_dw2,ls_opc,ls_dw,ls_user
long ll_codigo

istr_parm = message.powerobjectparm 

uo_toolbarstrip.visible = false
dw_1.visible = false
of_getwindow()

ids_datastore   = istr_parm.ads_menu //aqui recupera el datastore
uo_powerdock = istr_parm.auo_powerdock 
is_button         = istr_parm.as_button
ls_dw              = ids_datastore.object.tDw1[1]
ls_dw2              = ids_datastore.object.tDw2[1]
is_tabla           = ids_datastore.object.tTabla[1]
is_window  		= ids_datastore.object.twindow[1]
ii_window  		= ids_datastore.object.bwindow[1]

is_entidad = ids_datastore.object.tEntidad[1]
if isnull(is_entidad) then is_entidad=''
iuo_tab            = istr_parm.auo_userobject 
iuo_grillamain  = istr_parm.auo_grillamaincabedet
iuo_tabmantomain = istr_parm.auo_tabmantocabedet
is_idcodigo			=  istr_parm.as_parm[1] //id tabla
if ls_dw = '' or isnull(ls_dw) then return

dw_1.dataobject=ls_dw //cabecera
dw_3.dataobject=ls_dw2//detalle
dw_1.settransobject(sqlca)
dw_3.settransobject(sqlca)
dw_2.dataobject=ls_dw
dw_4.dataobject=ls_dw2
//limpiar
dw_1.reset();dw_3.reset()
dw_2.reset();dw_4.reset()
st_titulo.text = ids_datastore.object.tTitulo[1]
st_det1.text = ids_datastore.object.tObse1[1]
st_det2.text = ids_datastore.object.tObse2[1]
il_error =0
//uo_1.of_BackColor2(of_GetColor("BACKGROUND2"))
uo_1.of_BackColor2(RGB(129,169,226))
//f_dataload('MITEM')
//event post ue_settabtext ('')
//EVENT ue_mostrar (istr_parm,true,0)



end event

event ue_cambio_opc;string ssas_button


choose case upper(as_button) 
	case 'NUEVO'
		f_proteger_dw( dw_3,0)
		uo_toolbarstrip.visible = TRUE
//		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', true)
		uo_toolbarstrip.of_setvisible( 'Imprimir',false)
		uo_toolbarstrip.of_setvisible( 'Editar', FALSE);
		uo_toolbarstrip.of_setvisible( 'Anular', FALSE)
		uo_toolbarstrip.of_setvisible( 'Grabar', TRUE)// ; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		uo_toolbarstrip.of_setvisible( 'Cancelar', TRUE)//;uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Agregar', TRUE)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', TRUE)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
		dw_1.visible = TRUE ; 		dw_3.visible = TRUE ; 	dw_2.visible =FALSE; 		dw_4.visible =FALSE
		dw_1.enabled = true ; dw_3.enabled=true
		event ue_settabtext( 'NUEVO')
	case 'EDITAR'
		f_proteger_dw( dw_3,0)
		uo_toolbarstrip.visible = TRUE
		dw_1.enabled = true ; dw_3.enabled=true
		dw_1.visible = true ; 		dw_3.visible = true ; 	dw_2.visible =false; 		dw_4.visible =false
		uo_toolbarstrip.of_setvisible( 'Imprimir', true)
		uo_toolbarstrip.of_setvisible( 'Editar', false);
		uo_toolbarstrip.of_setvisible( 'Anular', false)
		uo_toolbarstrip.of_setvisible( 'Grabar', true) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		uo_toolbarstrip.of_setvisible( 'Cancelar', true)//;uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Agregar', true)//; uo_toolbarstrip.of_setenabled( 'Agregar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', true)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', ab_ver)
		event ue_settabtext( 'EDITAR')
	case 'ANULAR'
		f_proteger_dw( dw_3,1)
		uo_toolbarstrip.of_setvisible( 'Imprimir', false)
		uo_toolbarstrip.visible = TRUE
		dw_1.enabled = false ; dw_3.enabled=false
		dw_1.visible = true ; 		dw_3.visible = true ; 	dw_2.visible =false; 		dw_4.visible =false
		uo_toolbarstrip.of_setvisible( 'Editar', false);
		uo_toolbarstrip.of_setvisible( 'Anular', false)
		uo_toolbarstrip.of_setvisible( 'Grabar', true) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		uo_toolbarstrip.of_setvisible( 'Cancelar', true)//;uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Agregar', false)//; uo_toolbarstrip.of_setenabled( 'Agregar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', false)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', ab_ver)
	case 'CANCELAR'	
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', false)
		dw_1.enabled = false ; dw_3.enabled=false
		uo_toolbarstrip.of_setvisible( 'Grabar', FALSE) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		dw_1.visible = FALSE ; 		dw_3.visible = FALSE ; 	dw_2.visible = TRUE; 		dw_4.visible =TRUE
		uo_toolbarstrip.of_setvisible( 'Cancelar', FALSE)
		uo_toolbarstrip.of_setvisible( 'Editar', false);
		uo_toolbarstrip.of_setvisible( 'Anular', TRUE)
		uo_toolbarstrip.of_setvisible( 'Agregar', FALSE)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', FALSE)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
		event ue_settabtext( 'Consultar')
	CASE 'CONSULTAR'
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', false)
		dw_1.enabled = false; dw_2.enabled = false
		uo_toolbarstrip.visible = TRUE
		uo_toolbarstrip.of_setvisible( 'Grabar', FALSE) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		dw_1.visible = FALSE ; 		dw_3.visible = FALSE ; 	dw_2.visible = TRUE; 		dw_4.visible =TRUE
		uo_toolbarstrip.of_setvisible( 'Imprimir', true)
		uo_toolbarstrip.of_setvisible( 'Cancelar', FALSE)
		uo_toolbarstrip.of_setvisible( 'Editar', true);
		//uo_toolbarstrip.of_setvisible( 'Anular', true)
		
		uo_toolbarstrip.of_setvisible( 'Agregar', FALSE)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', FALSE)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
	CASE 'DEFAULT'
		dw_1.enabled= false ;	dw_1.visible = false ;		dw_2.visible = false ;		uo_1.visible = true
		uo_toolbarstrip.visible = false ;		st_titulo.visible = true ;		st_det1.visible = true
		event ue_settabtext( 'PRINCIPAL')
	case	else 
//		uo_toolbarstrip.of_setvisible( 'Grabar', lb_sw) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
//		dw_1.visible = lb_sw ; 		dw_3.visible = lb_sw ; 	dw_2.visible = ab_ver; 		dw_4.visible =ab_ver
//		uo_toolbarstrip.of_setvisible( 'Cancelar', lb_sw)
//		uo_toolbarstrip.of_setvisible( 'Editar', ab_ver);
//		uo_toolbarstrip.of_setvisible( 'Anular', ab_ver)
//		uo_toolbarstrip.of_setvisible( 'Agregar', lb_sw)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
//		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', lb_sw)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
end choose

end event

event ue_anular;integer li_documento
string ls_stat
li_documento = dw_2.object.iddocumento[1]

select tstat into :ls_stat from vtadocu where iddocumento = :li_documento;

if ls_Stat = 'N' then 
	f_msg('El registro ya esta anulado',1)
	return
end if


iuo_tabmantomain.event ue_setbutton(is_button)
iuo_tabmantomain.event	ue_set_ib_sw(true)

iuo_grillamain.event ue_activa_opc( true)
event ue_settabtext ('Anular '+ is_entidad)
event ue_cambio_opc('ANULAR')
is_columna = dw_1.describe('#'+string(1)+'.name')
is_tipocolumna = dw_1.describe(is_columna+'.coltype')	

dw_3.GetChild("iditem", dwc);dwc.reset()
gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)

if left(is_tipocolumna,4)='char' then
	 is_codigo =dw_2.object.data[1,1]
	 of_retrieve( is_codigo)	
elseif is_tipocolumna='int' then
	 ii_codigo =dw_2.object.data[1,1]
	 of_retrieve( ii_codigo)	
else
	il_codigo =dw_2.object.data[1,1]
	 of_retrieve( il_codigo)	
end if		





end event

event ue_grabar_externo;long ll_movimiento = 0

//ll_movimiento = dw_1.object.iddocumento[1]
//
//If sqlca.Usp_Anular_MKARDEX( 'V',ll_movimiento) <> 0  Then
//	rollback USING SQLCA ;
//	f_msj('Error al ANULAR al kardex',1)
//	return -1
//End if
//of_retrieve(ll_movimiento)
//dw_2.reset();dw_4.reset();
//dw_1.RowsCopy(dw_1.GetRow(),dw_1.GetRow(), primary!, dw_2  , 1, Primary!)
//dw_3.RowsCopy(1,dw_3.Rowcount(), primary!, dw_4, 1, Primary!)
//dw_1.resetupdate();	dw_3.resetupdate(); 
//
//COMMIT USING SQLCA;
//
//iuo_grillamain.event dynamic ue_refrescar_row2(dw_2,dw_4,ii_row,is_button)
//MessageBox('Informaci$$HEX1$$f300$$ENDHEX$$n','El Proceso de anulacion se Realizo Exitosamente',information!)
//dw_4.GetChild("iditem", dwc);dwc.reset()
//gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)
//
//iuo_grillamain.event ue_activa_opc( false)
//this.event ue_cambio_opc('Consultar')
//this.event ue_settabtext( 'Consultar')
//
//dw_1.reset();dw_3.reset( )
//iuo_grillamain.event dynamic ue_activa_opc(false) 
//iuo_grillamain.event dynamic ue_bloquear_refrescar(false) 
//this.event ue_setdwc()


//dw_4.GetChild("iditem", dwc);dwc.reset()
//gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)
//iuo_grillamain.event ue_activa_opc( false)
//this.event ue_cambio_opc('CONSULTAR')
////this.event ue_ver_object(true)
//this.event ue_settabtext( 'Consultar')
return 1
end event

event ue_imprimir;call super::ue_imprimir;int ll_iddocumento
//ll_iddocumento = dw_1.object
decimal {2} ld_cantPrint = 15.00

dw_5.dataobject  = 'd_usp_printdocuvta'
dw_5.settransobject( sqlca)
dw_5.retrieve(il_documento,ld_cantPrint)
dw_5.print();commit;



end event

event ue_editar;iuo_tabmantomain.event ue_setbutton(is_button)
iuo_tabmantomain.event	ue_set_ib_sw(true)

iuo_grillamain.event ue_activa_opc( true)
event ue_settabtext ('Editar '+ is_entidad)
event ue_cambio_opc('EDITAR')
is_columna = dw_1.describe('#'+string(1)+'.name')
is_tipocolumna = dw_1.describe(is_columna+'.coltype')	
dw_1.enabled = false
dw_3.enabled = true
//dw_3.GetChild("iditem", dwc);dwc.reset()
//gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)

if left(is_tipocolumna,4)='char' then
	 is_codigo =dw_2.object.data[1,1]
	 of_retrieve( is_codigo)	
elseif is_tipocolumna='int' then
	 ii_codigo =dw_2.object.data[1,1]
	 of_retrieve( ii_codigo)	
else
	il_codigo =dw_2.object.data[1,1]
	 of_retrieve( il_codigo)	
end if		

end event

event ue_copy_fila_det;long ll_rows
INTEGER LI_ROW
dw_3.reset()
dw_4.reset(); dw_3.clear();dw_4.clear()
ii_sw =ai_sw
//ii_row  = ai_row

if ad_dw.rowcount() > 0 then
	dw_4.object.data = ad_dw.object.data
//	dw_4.GetChild("iditem", dwc);dwc.reset()
//	gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)
end if
event ue_setdwc()	
end event

type dw_5 from u_cst_mantocabedet`dw_5 within u_cst_museralma
end type

type dw_4 from u_cst_mantocabedet`dw_4 within u_cst_museralma
string dataobject = "d_museralma_tabular"
end type

type dw_3 from u_cst_mantocabedet`dw_3 within u_cst_museralma
end type

event dw_3::itemchanged;call super::itemchanged;DataWindowChild 	LdwChild
string ls_descripcion, ls_orden, ls_artic
long ll_registro
decimal{4} ld_fm_precio 
decimal{2} ld_fm_dcto1 , ld_fm_dcto2 , ld_fm_dcto3 , ld_fm_dcto4
double ld_cant,ld_nstock
integer li_item	,li_alma
Choose Case dwo.name
	Case 'iditem'
		//-- Verifica si es valido
		If Trim(data) = '' Or IsNull(data) Then
			Messagebox('Sistema','Error, Digite un C$$HEX1$$f300$$ENDHEX$$digo Valido', StopSign!)
			Return 1
		End If
//		li_item = integer (data)
//		li_alma = Object.idalma[ row ]
		//-- Recupera las unidades de medida
//		This.GetChild('idunid',LdwChild)
//		LdwChild.SetTransObject(SQLCA)
//		LdwChild.Retrieve(li_item,'V')
//		if ldwChild.RowCount() <> 0 then
//			Object.idunid[ row ] = ldwChild.GetItemString( 1 ,1)
//		end if
		
//		sqlca.usp_getstockmitemalma( li_item, li_alma, ld_nstock)
//		Object.nstock[ row ] = ld_nstock
//		//-- Verifica si ya fue ingresado
		If find('string(iditem)="'+data+'"',1, RowCount()) >0 Then
//			this.object.iditem[row] = null
			Messagebox('Sistema','El item ya Fue Registrado Anteriormente, Digite uno Valido', StopSign!)
			Return 1
		End If
Case 'idunid'
		//-- Si es valido
		If Trim(data) = '' Or IsNull(data) Then
			Messagebox('Sistema','Error, Digite un C$$HEX1$$f300$$ENDHEX$$digo Valido', StopSign!)
			Return 1
		End If

//		//-- Verifica si existe
//		ls_descripcion = Space(40)
//		SQLCA.sp_cat_mat_unidad_medida(data,ls_descripcion)
//		If Trim(ls_descripcion) = '' Then
//			Messagebox('Sistema','Error, C$$HEX1$$f300$$ENDHEX$$digo No Registrado, Digite uno Valido', StopSign!)
//			Return 1
//		End If
//
//		//-- Verifica las unidades de destino
//		ll_registro = 0
//		SQLCA.sp_alm_obt_aumalter(This.GetItemString(row,'cc_artic'),data,ll_registro)
//		If ll_registro = 0 Then
//			Messagebox('Sistema','Error, Unidad de Medida no Asignada al Art$$HEX1$$ed00$$ENDHEX$$culo, Digite Uno Valido', StopSign!)
//			Return 1
//		End If

	case 'npreciobase'
		post event ue_sumar()
//		  this.object.ntotal[row] = this.getitemDecimal( row,'ncant') *  double (data)
//	case ''
end choose
end event

event dw_3::ue_dropdowndw;call super::ue_dropdowndw;//DataWindowChild 	LdwChild
//
//This.GetChild('idunid',LdwChild)
//LdwChild.SetTransObject(SQLCA)
//LdwChild.InsertRow(0)
//
Return 1
//
end event

event dw_3::itemerror;call super::itemerror;Return 1
end event

event dw_3::rowfocuschanged;call super::rowfocuschanged;////-- Recupera las unidades de medida
//If currentRow<=0 Then Return
//integer li_item 
//datawindowchild ldwc_1
//this.getchild('idunid',ldwc_1);ldwc_1.reset()
//ldwc_1.settransobject(sqlca)
//li_item  = Object.iditem[currentrow]
//if isnull(li_item ) then li_item =1
//ldwc_1.Retrieve(li_item,'V')
//
end event

type st_det2 from u_cst_mantocabedet`st_det2 within u_cst_museralma
end type

type st_det1 from u_cst_mantocabedet`st_det1 within u_cst_museralma
end type

type st_titulo from u_cst_mantocabedet`st_titulo within u_cst_museralma
end type

type dw_2 from u_cst_mantocabedet`dw_2 within u_cst_museralma
string dataobject = "d_malma_free"
end type

type uo_toolbarstrip from u_cst_mantocabedet`uo_toolbarstrip within u_cst_museralma
end type

event uo_toolbarstrip::ue_buttonclicked;string ls_columna,ls_tipo,ls_codigo
integer li_codigo
long ll_codigo,ll_opc


choose case upper(as_button)
	case 'IMPRIMIR'	
		il_documento = dw_2.object.data [1,1]
		event ue_imprimir()
		update vtadocu set bimpreso = 1 where iddocumento = :il_documento;
		commit;
		dw_1.retrieve(il_documento)
		dw_2.object.data=dw_1.object.data
		commit;
		
		//event ue_copy_fila(dw_2, 1, 1)
	case 'IMPRIMIR-GRABAR'	
		ib_printGrabar = true
		event  ue_grabar( )
	case 'ANULAR'
		is_button = as_button
		event ue_anular()
	case 'ELIMINAR FILA'
		EVENT ue_eliminar_detalle()
	case 'AGREGAR'
		//FOR ll_codigo = 1 to 10000
			event ue_agregar()
		//next
	case 'EDITAR'
			is_button = as_button
			event ue_editar()
	case 'GRABAR'
		ib_printGrabar = false
		event  ue_grabar( )
	case 'CANCELAR'
		
	   if upper(is_button) ='NUEVO' then 
			is_button ='DEFAULT'
		ELSE
			is_button ='CANCELAR'
	   end if	
	  // is_button = as_button
       event ue_cancelar()

END CHOOSE
end event

event uo_toolbarstrip::constructor;this.of_AddItem('Grabar', 'Save!')
//this.of_AddItem('Imprimir-Grabar', 'Print!')
this.of_AddItem('Editar', '..\IMG\ICO\edit.ico')
//this.of_AddItem('Anular', '..\IMG\ICO\Error.ico')
this.of_AddItem('Agregar', 'Insert5!')
this.of_AddItem('Eliminar Fila', 'DeleteRow!')
this.of_AddItem('Cancelar', 'Undo!')
//this.of_AddItem('Imprimir', 'Print!')


//opciones en estado invisible
this.of_setvisible( 'Grabar', false)
this.of_setvisible( 'Agregar', false)
this.of_setvisible( 'Eliminar Fila', false)
this.of_setvisible( 'Cancelar', false)
//this.of_setvisible('Imprimir-Grabar', false)
//this.of_setvisible('Imprimir', false)
//esto es para mostar los textos
this.of_DisplayText(true)



end event

type dw_1 from u_cst_mantocabedet`dw_1 within u_cst_museralma
end type

type uo_1 from u_cst_mantocabedet`uo_1 within u_cst_museralma
end type

